package testenv.model.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import testenv.model.AbstractBaseEntity;



@Entity
@SequenceGenerator(name="structureversion_id_seq", sequenceName="structureversion_id_sequence")
public class StructureVersion extends AbstractBaseEntity {
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="structureversion_id_seq")
	@GenericGenerator(
	     name="structureversion_id_seq",
	     strategy="sequence",
	     parameters= {
	         @Parameter(name="minvalue", value="1"),
	         @Parameter(name="increment", value="1"),
	         @Parameter(name="sequence", value="structureversion_id_sequence")
	         })
	private Integer id = null;
	
	@ManyToOne
	private Structure structure = null;
	
	@Column(nullable=false)
	private Date structureVersionDate = null;
	
	@Column(nullable=false, length=20)
	private String version = null;
	
	
	@OneToMany(mappedBy="structureVersion", cascade=CascadeType.ALL)
	@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
	private List<StructureElementGroup> structureElementGroup = new ArrayList<StructureElementGroup>();
	
	
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Structure getStructure() {
		return structure;
	}

	public void setStructure(Structure structure) {
		this.structure = structure;
	}
	

	public Date getStructureVersionDate() {
		return structureVersionDate;
	}

	public void setStructureVersionDate(Date structureVersionDate) {
		this.structureVersionDate = structureVersionDate;
	}

	public List<StructureElementGroup> getStructureElementGroup() {
		return structureElementGroup;
	}

	public void setStructureElementGroup(
			List<StructureElementGroup> structureElementGroup) {
		this.structureElementGroup = structureElementGroup;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}
	
	
}
